﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


using CRM.Entity;
using CRM.BLL;
using DP.Web.UI;
using DP.Common;

namespace CRM.Web.MessagingManage
{
    public partial class FaxReceiveShow : Common.PageBase
    {

        T_FAX_RECV_BLL bll = new T_FAX_RECV_BLL();
        T_BUSINESSDIVISION_BLL bdBll = new T_BUSINESSDIVISION_BLL();
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            PageHelper.SetPrePageUrl(this.Page);
            PageHelper.SetGoBackUrl(this.Page, btnCancel, StaticConstant.NotBackUrl);

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                pageDataInit();
            }
        }




        private void pageDataInit()
        {
            string _autoid = String.IsNullOrEmpty(Request.QueryString["AUTOID"]) ? "" : Request.QueryString["AUTOID"].Trim();

            if (!String.IsNullOrEmpty(_autoid))
            {
                T_FAX_RECV_Entity entity = bll.GetEntity("AUTOID", _autoid);

                txtUNAME.Text = entity.UNAME;
                txtFAX.Text = entity.FAX;
                txtPAGES.Text = entity.PAGES.ToString();
                txtSDATE.Text = entity.CREATETIME.HasValue? entity.CREATETIME.Value.ToString("yyyy-MM-dd"): "";
                txtSTIME.Text = entity.CREATETIME.HasValue ? entity.CREATETIME.Value.ToString("HH:mm:ss") : "";
                txtSUBJ.Text = entity.SUBJ;
                txtSINFO.Text = entity.SINFO;
                HyperLink hl = new HyperLink();
                hl.ID = "hlFileName";
                if (!String.IsNullOrEmpty(entity.FILENAME))
                {
                    hl.Text = GetFileName(entity.FILENAME);
                    hl.NavigateUrl = entity.FILENAME;
                }
                else
                {
                    hl.Visible = false;
                }
                plFILENAME.Controls.Add(hl);
            }

        }

        private string GetFileName(string input)
        {
            return input.Substring(input.LastIndexOf("\\") + 1);
        }



    }
}
